import React from 'react'
import './index.css'

class Clock extends React.Component {
    constructor() {
        super()
        this.state = {
            date: new Date()
        }
    }

    componentDidMount() {
        setInterval(() => {
            this.tick()
        }, 1000)
    }

    tick() {
        this.setState({
            date: new Date()
        })
    }

    render() {

        return (
            <div>
                <h1> Hellow World </h1>
                <p>Now time is {this.state.date.toLocaleTimeString()}</p>
            </div>
        );
    }
}

export default Clock;